const Koa = require('koa');
const parser = require('koa-bodyparser');
const path = require('path');
const cors = require('@koa/cors');
const InitManager = require('./core/InitManager');
const catchError = require('./core/catchError');

const app = new Koa();
app.use(catchError);
app.use(cors());
app.use(parser()); // 会将解析后的值挂到ctx.request.body上
app.use(require(path.join(__dirname, './app/middleware/adminAuth')));
app.use(require(path.join(__dirname, './app/middleware/userAuth')));
InitManager.initCore(app);

app.listen(9669, () => {
  console.log(`server is running at 9669`);
});
